const Koa = require('koa');
const mongoose = require("mongoose");
const bodyParser = require('koa-bodyparser')
const cors = require('@koa/cors'); //解决跨域
const config = require('./config')
const router = require("./routes")

const app = new Koa();

//连接数据库
mongoose.connect(config.db)

app.use(bodyParser())
app.use(cors())
app.use(router.routes()).use(router.allowedMethods())


app.listen(config.port, () => {
    console.log('服务已启动');
})